<?php

include_once("core/controller.php");
include_once("core/versionHandler.php");

/**
 * deleteUser
 *
 * @copyright inovia
 * @package oolime_manager 
 */
class DeleteUser extends Controller{
  
  public function isLegitimate(){
    // Inputs verifications
    $tabVerify = Array(
	    "id"  => Array("unsigned int","Bad id")
	  );
	  return $this->request->check($tabVerify);
  }
  
  public function actions(){
  
    include_once("core/user.php");
    $checkUser = new User('rw','id',$this->request->get('id'));

    if($checkUser->isOk()){
	    $checkUser->delete();
	    $checkUser = null;
	    
	    //adds a node to say that it has been deleted
	    $Node = $this->response->doc->createElement("deleted");
	    $this->response->root->appendChild($Node);
	    
    }else{
      $this->response->addError('This user does not exist','id');
    }
    
    $this->defaultActions();
  }
  
  public function defaultActions(){
    $versionH=new VersionHandler("");
    $this->response->add($versionH->getMyVersion());
    include_once("controls/manager/homeUsers.php");
    new homeUsers();
  }
}

?>
